{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 决策树"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import matplotlib.pyplot as plt\n",
    "from sklearn import datasets"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "iris = datasets.load_iris()\n",
    "X = iris.data[:, 2:]\n",
    "y = iris.target"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXcAAAD8CAYAAACMwORRAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvNQv5yAAAGgFJREFUeJzt3X2QXXV9x/H3d282JoaHjGYhMQkGJeAoAoEdHoyjmVojDylJrRGY+hCHSsdKhYnaESdTI8YpHTpoKlQagQKVRkjAEAmWUtGqpaFuApLKkxjQBAJZQIKJQZLdb/+4N8nu3XNzf+ees/c83M9rJpO9Z3/nnO+FyXfPnvv5/Y65OyIiUi5dWRcgIiLpU3MXESkhNXcRkRJScxcRKSE1dxGRElJzFxEpITV3EZESUnMXESkhNXcRkRIak9WJJ02a5DNmzMjq9CIihbRhw4YX3L2n2bjMmvuMGTPo6+vL6vQiIoVkZr8OGafbMiIiJaTmLiJSQmruIiIlpOYuIlJCau4iIiWk5i4iUkJq7iIiJdQ0525m04GbgcnAILDC3ZfXjZkD3Ak8Vdt0h7tfnm6pIlJ06zavY/nG5Ty36zkmT5jMJSdfwjlvOSfR/kCiY5ZVyCSmvcBn3X2jmR0KbDCze939kbpxP3H3eemXKCJlsG7zOpbev5RXB14FYNuubSy9fylAUDOO2n/JT5dgZuwZ3NPSMcus6W0Zd9/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Y2KCJ33+buG2tf/w54lJGLshWCV+2sveyu/SnWlcMQZjYNOAe4LutapMrMDgPeA1wP4O6vFb2x17wP+FWajR0K2NzLysxmUJ3h+0C2lbSudhvjIWA7cK+7F/a9UJ2R/TfAYNaFpMCB/zCzDWZ2UdbFJPAWoB/4l9rtsuvMrAzPvzwfWJn2QdXcc8DMDgFuBy5191eyrqdV7j7g7idRXVzuVDMr5G0zM5sHbHf3DVnXkpLZ7n4y1QfufLp2a7OIxgAnA99091nALuAL2ZaUTO3W0rnAqrSPreaesdr96duBW9z9jqzrSUPtV+UfAWdmXEqrZgPn1u5Vfwf4IzP7drYltc7dn639vR34LtUH8BTRVmDrkN8IV1Nt9kV2FrDR3Z9P+8Bq7hmqfQh5PfCou1+VdT1JmFmPmU2sfT0e+GPgsWyrao27X+bu09x9BtVfme9z949kXFZLzGxC7cN6arcw5gKFTJq5+3PAFjM7rrbpfUDhwgd1LmAUbslA9decQjGzlcAcYJKZbQW+5O7XZ1tVy2YDHwU21e5VA3zR3e/OsKZWTQFuqn3y3wXc5u6FjhCWxJHAd2tPvRwD/Ju7/3u2JSXy18AttdsZm4FPZFxPy8zs9cD7gb8cleMXLQopIiLN6baMiEgJqbmLiJSQmruISAmpuYuIlJCau4hICam5i4iUkJq7iEgJqbmLiJTQ/wMx8DMUmXaorgAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x1ed01d2c320>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.scatter(X[y==0,0],X[y==0,1])\n",
    "plt.scatter(X[y==1,0],X[y==1,1])\n",
    "plt.scatter(X[y==2,0],X[y==2,1])\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "DecisionTreeClassifier(class_weight=None, criterion='entropy', max_depth=2,\n",
       "            max_features=None, max_leaf_nodes=None,\n",
       "            min_impurity_decrease=0.0, min_impurity_split=None,\n",
       "            min_samples_leaf=1, min_samples_split=2,\n",
       "            min_weight_fraction_leaf=0.0, presort=False, random_state=None,\n",
       "            splitter='best')"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from sklearn.tree import DecisionTreeClassifier\n",
    "\n",
    "dt_clf = DecisionTreeClassifier(max_depth=2, criterion='entropy')\n",
    "dt_clf.fit(X, y)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "def plot_decision_boundary(model, axis):\n",
    "    x0, x1 = np.meshgrid(\n",
    "        np.linspace(axis[0], axis[1], int((axis[1]-axis[0])*100)),\n",
    "        np.linspace(axis[2], axis[3], int((axis[3]-axis[2])*100))\n",
    "    )\n",
    "    x_new = np.c_[x0.ravel(), x1.ravel()]\n",
    "    \n",
    "    y_predict = model.predict(x_new)\n",
    "    zz = y_predict.reshape(x0.shape)\n",
    "    from matplotlib.colors import ListedColormap\n",
    "    custom_cmap = ListedColormap(['#EF9A9A', '#FFF59D', '#90CAF9'])\n",
    "    plt.contourf(x0, x1, zz, linewidth=5, cmap=custom_cmap)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### *这里开始对 plot_decision_boundary 函数做些试验和思考*"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[0.   0.25 0.5  0.75 1.  ]\n",
      " [0.   0.25 0.5  0.75 1.  ]\n",
      " [0.   0.25 0.5  0.75 1.  ]]\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "array([[0. , 0. , 0. , 0. , 0. ],\n",
       "       [0.5, 0.5, 0.5, 0.5, 0.5],\n",
       "       [1. , 1. , 1. , 1. , 1. ]])"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "x = np.linspace(0,1,5)\n",
    "y = np.linspace(0,1,3)\n",
    "x0, x1 = np.meshgrid(x,y)\n",
    "print(x0)\n",
    "x1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([0.  , 0.25, 0.5 , 0.75, 1.  , 0.  , 0.25, 0.5 , 0.75, 1.  , 0.  ,\n",
       "       0.25, 0.5 , 0.75, 1.  ])"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "x0.ravel()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([0. , 0. , 0. , 0. , 0. , 0.5, 0.5, 0.5, 0.5, 0.5, 1. , 1. , 1. ,\n",
       "       1. , 1. ])"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "x1.ravel()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[0.  , 0.  ],\n",
       "       [0.25, 0.  ],\n",
       "       [0.5 , 0.  ],\n",
       "       [0.75, 0.  ],\n",
       "       [1.  , 0.  ],\n",
       "       [0.  , 0.5 ],\n",
       "       [0.25, 0.5 ],\n",
       "       [0.5 , 0.5 ],\n",
       "       [0.75, 0.5 ],\n",
       "       [1.  , 0.5 ],\n",
       "       [0.  , 1.  ],\n",
       "       [0.25, 1.  ],\n",
       "       [0.5 , 1.  ],\n",
       "       [0.75, 1.  ],\n",
       "       [1.  , 1.  ]])"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.c_[x0.ravel(), x1.ravel()]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### *以上思考结束, 接下来回到决策树正轨上来*"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "C:\\Users\\fangyang\\Anaconda3\\lib\\site-packages\\matplotlib\\contour.py:967: UserWarning: The following kwargs were not used by contour: 'linewidth'\n",
      "  s)\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXcAAAD8CAYAAACMwORRAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvNQv5yAAAHBhJREFUeJzt3XuQXOV55/HvMxckNBohbElIgECmIDaYDWBmZWztuqjYYUGijIuYXXlrvbHLFW1lDQu7rtpacAowa4ektsqOynjjUoANJCzEXOwoQcTEZSdcHC4jWcSA2DKLzUqRYADdRjfQzDz7R5+Z6Tlzevrt7tN9Lv37VE3R5+33nH4kSo+Ozvn1e8zdERGRcunJugAREUmfmruISAmpuYuIlJCau4hICam5i4iUkJq7iEgJ1W3uZjbfzJ4zsxfM7CUz+1rCnHlm9hdm9qqZPWtmq9pRrIiIhAk5c38X+A13vwC4ELjczC6JzfkSsM/dzwa+BfxhumWKiEgj6jZ3rzgUbfZHP/FvPl0F3BO9fgj4pJlZalWKiEhD+kImmVkvsBU4G/iOuz8bm3IasBPA3cfM7ADwfuDt2HE2ABsATjhx4OJTzvxga9WLiHSZna9se9vdl9abF9Tc3X0cuNDMFgPfN7Pz3f3FqilJZ+mz1jVw903AJoAzzr3Yv3LvP4R8vIiIRG5YPe/1kHkNpWXcfT/wd8Dlsbd2ASsBzKwPOAnY28ixRUQkPSFpmaXRGTtmdiLwKeCV2LTNwG9Hrz8L/Ni1IpmISGZCLsusAO6Jrrv3AN9z9782s9uAYXffDNwF/JmZvUrljH192yoWEZG66jZ3d/9H4KKE8ZurXh8Drkm3NBERaZa+oSoiUkJq7iIiJaTmLiJSQmruIiIlpOYuIlJCau4i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1VDVkDfB74eXTtGuAmd9+SYU2hVgD3REmBHuB77l64OGGBnQJ8P3qUQh/wv939b7ItqWHXAfdFlzZeA76YcT0NMbMFwG8C/yHzWsoWhRQREV2WEREpJTV3EZESUnMXESkhNXcRkRJScxcRKSE1dxGRElJzFxEpof8PD4I4mMhFbdkAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x1ed01f695c0>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plot_decision_boundary(dt_clf, axis=[0.5, 7.5, 0, 3])\n",
    "plt.scatter(X[y==0,0],X[y==0,1])\n",
    "plt.scatter(X[y==1,0],X[y==1,1])\n",
    "plt.scatter(X[y==2,0],X[y==2,1])\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 信息熵\n",
    "\n",
    "### $H= -\\sum_{i=1}^{k} p_i log(p_i)$ 熵越大, 越不稳定, 越不确定"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1.0986122886681096\n",
      "0.8018185525433373\n",
      "0.00025025830929809126\n"
     ]
    }
   ],
   "source": [
    "a = [1/3, 1/3, 1/3]\n",
    "b = [1/10, 2/10, 7/10]\n",
    "c = [0.99998, 0.00001, 0.00001]\n",
    "entropy_a = sum([-i*np.log(i) for i in a])\n",
    "entropy_b = sum([-i*np.log(i) for i in b])\n",
    "entropy_c = sum([-i*np.log(i) for i in c])\n",
    "print(entropy_a, entropy_b, entropy_c ,sep='\\n')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [],
   "source": [
    "def entropy(p):\n",
    "    return -p*np.log(p) - (1-p)*np.log(1-p)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [],
   "source": [
    "x = np.linspace(0.01, 0.99, 200)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXcAAAD8CAYAAACMwORRAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvNQv5yAAAIABJREFUeJzt3Xd8lfXd//HX52QnZEEGIQkkgQQIICtsEdyoFdyCkzqoWmtr1621tb3t3XFrq71rsRZX1SponYgoOHCwCZswE2b2gOydfH9/JPaX0kAO5JxznfF5Ph48HjknX5P3ZfDtN9/rur6XGGNQSinlXWxWB1BKKeV4Wu5KKeWFtNyVUsoLabkrpZQX0nJXSikvpOWulFJeSMtdKaW8kJa7Ukp5IS13pZTyQv5WfeOYmBiTkpJi1bdXSimPtHnz5nJjTGxP4ywr95SUFLKzs6369kop5ZFE5Ig943RZRimlvJCWu1JKeSG7yl1EZonIPhHJFZGHuvn8UyKyrfPPfhGpdHxUpZRS9upxzV1E/ICFwMVAPrBJRJYaY3Z/M8YY82CX8d8Dxjohq1JKKTvZM3OfCOQaYw4aY5qBJcCc04yfByx2RDillFJnx55yTwSOdXmd3/nefxCRQUAq8HnvoymllDpb9pS7dPPeqR7fNBd4yxjT1u0XElkgItkikl1WVmZvRqWUUmfInuvc84HkLq+TgMJTjJ0LfPdUX8gYswhYBJCVlaXP91MuZ4yhsr6F0pomSmsaOVHfQmNzGw0tnX+a2xCBAD8bAX6Cv81GUICNvqGBRIcF0jcskOjQQPqFBWKzdTfvUco92FPum4B0EUkFCugo8JtOHiQiQ4FoYJ1DEyp1Fk7UNbO3uIa8slryymrJLa3lUHkdpdVNNLe19/rrB/rZSO4bwqB+YQzsG0pqTBiZAyLITIggLMiyewOV+pce/xYaY1pF5H5gBeAHvGiMyRGRx4BsY8zSzqHzgCVGn7itXKy1rZ3dRdVsPVrJ1qMn2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ZLkvnPPYc96+AW0QkH1gOfM810Sx3ph3QI+c/pfXMdDcDP/lyHnvGeBq7j0lEbgGygBlOTeQapz1uEbEBTwHzXRXIRez5efvTsTQzk47f0r4WkZHGmEonZ3Mme457HvB3Y8wfRWQK8Grncbc7P56lHN5r7jZzzweSu7xO4j9/LfvXGBHxp+NXt9P9uuMJ7DluROQi4BFgtjGmyUXZnKmn4w4HRgJfiMhhOtYil3rBSVV7/56/b4xpMcYcAvbRUfaezJ7jvhN4E8AYsw4IpmPvFW9nVwecCXcr901AuoikikggHSdMl540Zilwe+fH1wGfm84zEh6sx+PuXJ74Gx3F7g3rr9DDcRtjqowxMcaYFGNMCh3nGmYbY7Ktiesw9vw9f4+Ok+iISAwdyzQHXZrS8ew57qPAhQAiMpyOci9zaUprLAVu67xqZjJQZYwp6tVXtPos8inOGu+n46z6I53vPUbHf9TQ8cP+J5ALbATSrM7souP+FCgBtnX+WWp1Zlcc90ljv8ALrpax8+ctwJPAbmAnMNfqzC467kxgDR1X0mwDLrE6s4OOezFQBLTQMUu/E7gHuKfLz3th57+XnY74e653qCqllBdyt2UZpZRSDqDlrpRSXkjLXSmlvJCWu1JKeSEtd6WU8kJa7kop5YW03JVSygtpuSullBf6f2LSvo9kyHKxAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x1cdd7218a20>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.plot(x, entropy(x))\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
